package com.juc.blockingQueue.LinkedTransferQueue.transfer1;

public class ThreadB2 extends Thread{

	/**
	 * transfer()
	 * 1.如果当前存在一个正等待获取值的消费者线程，则把数据立即传输过去；
	 * 2.否则会将元素插入到队列尾部，并将进入阻塞状态，直到有消费者线程
	 * 取走该元素.
	 */
	private MyServiceB service;
	
	public ThreadB2(MyServiceB service) {
		super();
		this.service = service;
	}
	@Override
	public void run() {
	    try {
			System.out.println(Thread.currentThread().getName() + "  beginB  " + System.currentTimeMillis());
			service.queue.transfer(" 我从ThreadB2来 ");
			System.out.println(Thread.currentThread().getName() + "  endB  " + System.currentTimeMillis());

		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
